Skip to content

fix(mcp): stdio list_datasets localizes the dataset catalogue for the workspace default locale - #34833

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34787-stdio-list-datasets-locale
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34787-stdio-list-datasets-locale

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs

Closes #34787

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:stdio 通道的 list_datasets / query_dataset 读到的数据集,现在先用 HTTP 通道同一个翻译函数(@objectstack/rest 的 translateMetaList)按工作区默认语言翻译,再交给执行器展示和匹配。
  • 为什么改:ADR-0149 D2 规定数据集目录"在元数据边界按调用者语言本地化",没有通道例外;之前默认语言为 zh-CN 的工作区,stdio 只显示英文标签,「总金额 / 平均成交额 / 阶段」一个都不命中,而 HTTP(不带语言头)全部按 label 命中。
  • 风险与回滚:@objectstack/mcp 新增对 @objectstack/rest 的运行时依赖(实测 os CLI 入口本来就加载它);i18n 服务取不到时保持原来的未翻译列表。回滚即 revert 本 PR。
  • 先看:packages/mcp/src/stdio-data-bridge.ts(loadDatasets 的翻译步骤)、packages/mcp/package.json(新依赖)、packages/mcp/vitest.config.ts(两条源码 alias)。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/stdio-data-bridge.dataset-locale.test.ts,预期 4 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

  • packages/mcp/src/stdio-data-bridge.ts: the stdio bridge's loadDatasets (the one source both list_datasets and query_dataset read) now runs translateMetaList(sources, 'dataset', items) from @objectstack/rest, the call packages/runtime/src/domains/mcp.ts makes on the HTTP door. Its three sources mirror the HTTP door's: the i18n service (a resolver that throws or answers nothing means none), the merged protocol read for the packaged base (or none on a host without one), and metaRequestLocale(undefined, i18n) for the locale. With no request, that answers the i18n service's default, which is what the HTTP door answers for a call with no Accept-Language. No new locale source and no per-call locale.
  • StdioDataBridgeDeps gains an optional i18n?: () => unknown, and packages/mcp/src/plugin.ts passes () => optionalService('i18n'), resolved at each use like the protocol and security services. @objectstack/mcp exports nothing new.
  • packages/mcp/package.json: @objectstack/rest added to dependencies, @objectstack/service-analytics added to devDependencies (the test's stand-in executor matches terms with the platform's matchDatasetTerms). pnpm-lock.yaml adds the two importer links.
  • packages/mcp/vitest.config.ts: anchored source aliases for @objectstack/rest and @objectstack/service-analytics. Without them, check:test-source-alias would need two new rows in its shrink-only ledger.
  • .changeset/34787-stdio-list-datasets-locale.md: a patch for @objectstack/mcp.

Not touched: dataset-term-matcher.ts, matching other locales' bundle values (#34720's open fork), candidates, the HTTP door, and a per-call stdio locale.

Translator route: import from @objectstack/rest

I measured two routes. Importing from @objectstack/rest was chosen over a thin wrapper around translateMetadataDocument:

  • translateMetaList does more than call translateMetadataDocument. It also resolves the packaged base (packagedObjectBaseOf) and a declared override's pair bundle (pairTranslationBundleOf), and it applies the translate options (metaTranslateOptions: fallback chain and source locale). A wrapper would have to copy those or drop them. Either way the two transports would stop agreeing.
  • Precedent: packages/plugins/plugin-auth/src/invitation-role-label.ts already imports translateMetaList from @objectstack/rest.
  • No cycle: @objectstack/rest does not depend on @objectstack/mcp (check:workspace-manifest-cycles exit 0).
  • Cost, measured from a real load of the built packages/mcp/dist/index.js (ESM, module-init set collected through module.registerHooks), at 3bbda33 and at this head:
    • before: 379 modules, 17 packages; after: 400 modules, 25 packages;
    • the 8 added packages are @objectstack/rest, @objectstack/metadata, @objectstack/observability, @objectstack/platform-objects, chokidar, glob, js-yaml and readdirp.
    • The built packages/cli/dist/index.js (the os host that runs the stdio transport) already loads all 8. @objectstack/runtime imports @objectstack/rest statically. So the cost falls only on a host that embeds @objectstack/mcp without the runtime.
    • check:lean-entry-closure guards only @objectstack/objectql/core and stays green.

Why

ADR-0149 D2 says the list_datasets source is "localized at the metadata boundary for the caller's locale the way the REST door localizes a saved dataset". It names no transport exception. On #34720, live readings on a copy of app-crm with i18n.defaultLocale: 'zh-CN' showed the gap (comment 6945257866). The stdio door showed English labels and matched none of 总金额 / 平均成交额 / 阶段. HTTP with no header matched all three as label.

Tests

packages/mcp/src/stdio-data-bridge.dataset-locale.test.ts (new). The bridge runs over a dataset with zh-CN bundle labels. A stand-in executor lists what the bridge loaded and runs the platform's matchDatasetTerms over it:

  • zh-CN default: the catalogue shows 商机指标 / 阶段 / 总金额; 总金额 → measures.total_amount · label; 阶段 → dimensions.stage · label.
  • en default: authored labels, and the zh-CN term does not hit (today's result).
  • An i18n resolver that throws: the untranslated list, not an error.
  • A host with no i18n service: the untranslated list.

Ablation (one-time proof, committed fix first, scripts/ablation-replace.mjs):

  • The anchor return Array.isArray(translated) ? translated : items; was replaced by return items; /* ABLATED-34787 */. Landing was confirmed (anchor 1 → 0, blob 5dad1618 → 721eb27b).
  • With the mutation, the zh-CN case went red: expected 'Opportunity Metrics' to be '商机指标', 1 failed and 3 passed.
  • Restore: blob 5dad1618 equals the HEAD blob, and git diff HEAD is empty.
  • The test reaches the bridge through a relative import, so no build or dist/ sits on its path.

Acceptance notes

  • The stdio locale comes from the i18n service's getDefaultLocale(), as on the HTTP door with no header. The EntryLocalization that plugin.ts assembles for the stdio principal's ExecutionContext is not read here. On the readings below the two agreed.
  • Error handling copies the HTTP door: only the service resolution falls back to the untranslated list. A resolved i18n service whose getLocales / getTranslations throws reaches loadDatasets as a throw on both transports. The executor answers that as a degraded read. That case is not pinned here.
  • Because query_dataset resolves its dataset through the same loader, the provenance labels it prints over stdio are localized too. The HTTP door already behaves this way.
  • Open feat(mcp): list_objects and describe_object return the authored object and field description #34814 also edits stdio-data-bridge.ts, in a different region. overlap-check reports it merges cleanly.

Verification

All readings at head f12cb94021 unless stated.

Unit tests and typecheck
  • pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 (whole package, under the verify lock): Test Files 67 passed (67), Tests 1230 passed (1230), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/mcp typecheck: exit 0, with check:test-typecheck: OK.
  • eslint --no-inline-config on the four changed TypeScript files: exit 0. The repo-wide pnpm lint is CI's.
Live re-read: examples/app-crm copies, both transports, one boot each

Method: the worktree's own build, os dev -p PORT in a throwaway copy of examples/app-crm (deleted afterwards, never committed), and a persistent OS_HOME.

  • Boot 1 minted an API key with POST /api/v1/keys as the seeded admin.
  • Boot 2 used the same home with OS_MCP_STDIO_ENABLED=true and OS_MCP_STDIO_API_KEY. Over stdio it sent initialize and then tools/call list_datasets. Over HTTP, POST /api/v1/mcp with x-api-key.
  • Terms: 总金额, 平均成交额, 阶段, 客户, Total Amount, total_amount, Avg Deal Size. Avg Deal Size is the authored label of measures.avg_amount and is not a member name.

Copy with i18n.defaultLocale: 'zh-CN':

Call Catalogue labels matches (crm_opportunity_metrics)
stdio 商机指标 · 阶段 / 客户 / 成交日期 · 商机数 / 总金额 / 平均成交额 总金额 → measures.total_amount · label; 平均成交额 → measures.avg_amount · label; 阶段 → dimensions.stage · label; 客户 → dimensions.account · label; Total Amount → measures.total_amount · name; total_amount → measures.total_amount · name
HTTP, no Accept-Language same as stdio same as stdio
HTTP, Accept-Language: en Opportunity Metrics · Stage / Account / Close Date · Opportunities / Total Amount / Avg Deal Size 客户 → dimensions.account · synonym; Total Amount · name; total_amount · name; Avg Deal Size → measures.avg_amount · label
HTTP, Accept-Language: zh-CN same as stdio same as stdio

Copy with i18n.defaultLocale: 'en' (unchanged app-crm config):

Call Catalogue labels matches
stdio Opportunity Metrics · English 客户 → dimensions.account · synonym; Total Amount · name; total_amount · name; Avg Deal Size → measures.avg_amount · label
HTTP, no header as stdio as stdio
HTTP, en as stdio as stdio
HTTP, zh-CN zh-CN the six zh-CN-row hits

Avg Deal Size misses on both transports under the zh-CN default and hits as label under the en default.

Gates: dispatch-gates --commands, reconciled with --ran
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 84 commands. All 84 were run locally, each with its exit code captured before any pipe.
  • 83 exited 0. These include check:test-source-alias ("OK — 122 packages with tests scanned"), check:undeclared-dep-imports, check:workspace-manifest-cycles, check:lean-entry-closure, check:dts-closure, check:published-files and check:engine-double-contract.
  • NOT MEASURED: pnpm check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET: 14 packages outside this change have no dist/ in this worktree. A direct require('./packages/mcp/dist/index.cjs') loads, exit 0. CI's Lint & Repo Gates runs the gate over a full build.
  • dispatch-gates --ran with exit-annotated records: "84 derived famil(ies) accounted for — 83 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)", exit 0.
  • node scripts/check-nul-bytes.mjs: exit 0.
  • overlap-check against origin/main and the PRs that share paths (feat(mcp): list_objects and describe_object return the authored object and field description #34814, fix(settings)!: offer the knowledge settings only where the knowledge service is mounted #34223, chore: version packages #33849): clean, exit 0.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; eslint is clean on the changed files (the repo-wide pnpm lint is CI's).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: not touched.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is Chinese by the seat's template).
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

… workspace default locale

The stdio bridge's dataset loader now runs the HTTP door's /meta list
translation (translateMetaList from @objectstack/rest) for the i18n
service's default locale, so a zh-CN workspace serves zh-CN member labels
and a bundle-label term matches as label over stdio, as over HTTP with no
Accept-Language (ADR-0149 D2). An unresolvable i18n service leaves the
list untranslated.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
@github-actions github-actions Bot added size/m dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 2 changed file(s) yielded no anchor (packages/mcp/package.json, packages/mcp/vitest.config.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/mcp/package.json, packages/mcp/vitest.config.ts) — pages documenting those are invisible to this run
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json c513d62acdd342745bbfe29786ba4b644cd934fc → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 77ddeec7dd6e8c114e1f1bfa3b880a4387b96a11 — the merge of head f12cb94021cd6382dc1147883b82183b74373587 into base c513d62acdd342745bbfe29786ba4b644cd934fc, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 77ddeec7dd6e8c114e1f1bfa3b880a4387b96a11 && git checkout 77ddeec7dd6e8c114e1f1bfa3b880a4387b96a11
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c513d62acdd342745bbfe29786ba4b644cd934fc f12cb94021cd6382dc1147883b82183b74373587 && git checkout -B drift-repro c513d62acdd342745bbfe29786ba4b644cd934fc && git merge --no-ff f12cb94021cd6382dc1147883b82183b74373587

node scripts/docs-audit/affected-docs.mjs --json c513d62acdd342745bbfe29786ba4b644cd934fc

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzhshTXCAmv9KJXRZkB

L1 review · 2026-11-17T12:55Z

L1: ACCEPT
Head-sha: f12cb94

Read at this exact head: the 7 files (+221/−7), the body, card #34787, claim 6946458372, amendment 6948225307 and os-dev-report 6948178219. check-governed-merges: not governed, 228 lines. Check-runs on this sha: 69 total, 60 success, 9 skipped, 0 failed or pending.

Must-fix

None.

Should-fix

None.

Checklist

  • Shape: draft, Closes #34787. Both declaration lines (Clause-②: no, Metadata-protocol: none) are in the body and the changeset, and they match the claim. No export of @objectstack/mcp grows: StdioDataBridgeDeps.i18n is an optional member of an internal deps bag. So no holds, and no seat L2 is owed.
  • Surface: stdio-data-bridge.ts, plugin.ts, package.json (the claim's rest-import option), a card-named test and the changeset are inside the claim. vitest.config.ts, the @objectstack/service-analytics devDependency and the pnpm-lock.yaml importer links are covered by amendment 6948225307 as route-forced adds. No unrelated files.
  • Changeset: one @objectstack/mcp patch, the only published package whose src moved. It says the new runtime dependency on @objectstack/rest.
  • Change: loadDatasets runs translateMetaList(…, 'dataset', items) with inputs that mirror packages/runtime/src/domains/mcp.ts on the HTTP door. The i18n service is resolved per call, and a throwing resolver reads as none. The merged protocol is the packaged base. The locale is metaRequestLocale(undefined, i18n), which falls back to the i18n default, the same answer HTTP gives with no Accept-Language. A non-array result falls back to the untranslated list. @objectstack/rest does not depend on @objectstack/mcp, so there is no cycle (check:workspace-manifest-cycles exit 0 in the report). plugin-auth already imports translateMetaList the same way. The term matcher, candidates and the HTTP door are untouched, as the claim requires.
  • Tests: real commands are given. The whole mcp package passes (1230 tests) and typecheck passes. The new test has 4 cases: zh-CN default, en default, a throwing resolver, and no i18n service. The zh-CN case runs the real matchDatasetTerms and pins 总金额 and 阶段 as label. The ablation of the return line turns the zh-CN case red, and the restore is blob-verified. The test reaches the bridge through a relative import, so no dist/ is on its path.
  • Acceptance: met. Live readings on app-crm copies show stdio equal to HTTP with no header, under both a zh-CN and an en default. The "Avg Deal Size misses under zh-CN" reading is the reading first: does list_datasets match a member's translated label from a translation bundle, or only an inline label map #34720 ruling (6946563869), accepted in the amendment. It is not a gap of this card.
  • Docs made false: none found. git grep over content/docs, skills, docs and the mcp README at this head turns up no text that says stdio serves datasets untranslated. The plugin.ts comment that calls the workspace default the only stdio locale stays true. ADR-0149 D2 ("localized at the metadata boundary") is what this PR now satisfies on stdio.
  • UI strings: none added.

Notes

  • N1: The body's Human Minimum leaves the Before Submitting box unticked. This is a nit.
  • N2: The report's open question (keep the dispatch's <!-- signed: … --> HTML-comment line, which os-dev.md forbids) is the seat's convention call. It does not affect this verdict.
  • N3: As the body says, a resolved i18n service whose getLocales/getTranslations throws reaches the executor as a degraded read on both transports. That case has no pin. It is parity, not a regression.
  • N4: check:dual-build-cjs-loads was NOT MEASURED locally (exit 3, missing dists). CI's Lint & Repo Gates ran it on a full build and is green on this sha.

Under the "only nit-level findings open at landing" standard, nothing here blocks landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs

Landing · area o3-B · 2026-11-17T12:56Z

Probe Reading
L1 ACCEPT 6948646042 at f12cb94021cd6382dc1147883b82183b74373587 (= current head); no must-fix, no should-fix; notes N1 (unticked Before Submitting box) and N3 (no pin for an i18n service that throws after it resolves) are nits, sent to the seat for their own cards per the nit-only landing standard; N2 / N4 are notes, not findings
L2 (Clause-②: no) not owed (seat amendment 6948225307; no export of @objectstack/mcp grows)
Checks on head 60 success, 9 skipped, 0 failure / pending; mergeable_state: clean
check-governed-merges.mjs --pr 34833 NOT governed (0 of 7 paths hit the register); 228 changed lines ≤ 3000 (Tier S)
K (first-parent, merge-base..origin/main 0ad377c) 13 < 15; no merge=os-regen path in the diff

State change: ready for review + auto-merge (merge queue). Card #34787 closes on merge via Closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: the stdio door's list_datasets never localizes, so its catalogue and label matches ignore the workspace default locale (ADR-0149 D2)

2 participants